<template>
  <div class="summary-page">
    <div class="page-header">
      <h1 class="stagger-item">数据摘要</h1>
      <p class="page-description stagger-item">查看应用的整体数据统计和分析</p>
    </div>
    
    <div class="summary-stats">
      <div class="stat-card stagger-item">
        <div class="stat-icon">📊</div>
        <div class="stat-content">
          <div class="stat-value">{{ totalItems }}</div>
          <div class="stat-label">总项目数</div>
        </div>
      </div>
      
      <div class="stat-card stagger-item">
        <div class="stat-icon">📈</div>
        <div class="stat-content">
          <div class="stat-value">{{ activeCategories }}</div>
          <div class="stat-label">活跃分类</div>
        </div>
      </div>
      
      <div class="stat-card stagger-item">
        <div class="stat-icon">📅</div>
        <div class="stat-content">
          <div class="stat-value">{{ todayAdded }}</div>
          <div class="stat-label">今日新增</div>
        </div>
      </div>
      
      <div class="stat-card stagger-item">
        <div class="stat-icon">✅</div>
        <div class="stat-content">
          <div class="stat-value">{{ completionRate }}%</div>
          <div class="stat-label">完成率</div>
        </div>
      </div>
    </div>
    
    <div class="charts-section">
      <div class="chart-container">
        <h3>分类分布</h3>
        <div class="chart">
          <div 
            v-for="item in categoryDistribution" 
            :key="item.name"
            class="chart-bar"
            :style="{ width: item.percentage + '%' }"
            :title="`${item.name}: ${item.count}个项目`"
          >
            <span class="bar-label">{{ item.name }}</span>
            <span class="bar-value">{{ item.percentage }}%</span>
          </div>
        </div>
      </div>
      
      <div class="chart-container">
        <h3>月度趋势</h3>
        <div class="trend-chart">
          <div 
            v-for="month in monthlyTrend" 
            :key="month.name"
            class="trend-bar"
            :style="{ height: month.height + 'px' }"
            :title="`${month.name}: ${month.value}个项目`"
          >
            <span class="trend-value">{{ month.value }}</span>
            <span class="trend-label">{{ month.name }}</span>
          </div>
        </div>
      </div>
    </div>
    
    <div class="recent-activities">
      <h3>最近活动</h3>
      <div class="activities-list">
        <div 
          v-for="activity in recentActivities" 
          :key="activity.id"
          class="activity-item"
        >
          <div class="activity-icon">{{ activity.icon }}</div>
          <div class="activity-content">
            <div class="activity-title">{{ activity.title }}</div>
            <div class="activity-time">{{ activity.time }}</div>
          </div>
          <div class="activity-status" :class="activity.status">
            {{ activity.statusText }}
          </div>
        </div>
      </div>
    </div>
    
    <div class="export-section">
      <h3>数据导出</h3>
      <div class="export-options">
        <button class="export-btn" @click="exportData('csv')">
          <span class="export-icon">📋</span>
          导出CSV
        </button>
        <button class="export-btn" @click="exportData('pdf')">
          <span class="export-icon">📄</span>
          导出PDF
        </button>
        <button class="export-btn" @click="exportData('excel')">
          <span class="export-icon">📊</span>
          导出Excel
        </button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'

// 模拟数据
const totalItems = ref(156)
const activeCategories = ref(8)
const todayAdded = ref(12)
const completionRate = ref(78)

const categoryDistribution = ref([
  { name: '工作文档', count: 45, percentage: 29 },
  { name: '个人笔记', count: 32, percentage: 21 },
  { name: '学习资料', count: 28, percentage: 18 },
  { name: '图片收藏', count: 24, percentage: 15 },
  { name: '其他', count: 27, percentage: 17 }
])

const monthlyTrend = ref([
  { name: '1月', value: 18, height: 90 },
  { name: '2月', value: 22, height: 110 },
  { name: '3月', value: 25, height: 125 },
  { name: '4月', value: 30, height: 150 },
  { name: '5月', value: 35, height: 175 },
  { name: '6月', value: 26, height: 130 }
])

const recentActivities = ref([
  { id: 1, icon: '📝', title: '新建个人笔记', time: '10分钟前', status: 'success', statusText: '完成' },
  { id: 2, icon: '📄', title: '更新工作文档', time: '1小时前', status: 'success', statusText: '完成' },
  { id: 3, icon: '📚', title: '添加学习资料', time: '2小时前', status: 'success', statusText: '完成' },
  { id: 4, icon: '🖼️', title: '整理图片收藏', time: '3小时前', status: 'warning', statusText: '进行中' },
  { id: 5, icon: '📊', title: '生成数据报告', time: '5小时前', status: 'success', statusText: '完成' }
])

const exportData = (format) => {
  // 模拟导出功能
  alert(`正在导出${format.toUpperCase()}格式的数据...`)
  setTimeout(() => {
    alert(`数据已成功导出为${format.toUpperCase()}格式！`)
  }, 1000)
}
</script>

<style scoped>
.summary-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  min-height: 100vh;
}

.page-header {
  text-align: center;
  margin-bottom: 40px;
}

.page-header h1 {
  font-size: 2.2rem;
  color: #1e293b;
  margin-bottom: 10px;
}

.page-description {
  font-size: 1.1rem;
  color: #64748b;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.stat-card {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  padding: 30px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 5px 15px rgba(59, 130, 246, 0.3);
}

.stat-icon {
  font-size: 3rem;
  opacity: 0.9;
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: 2.5rem;
  font-weight: bold;
  margin-bottom: 5px;
}

.stat-label {
  font-size: 1rem;
  opacity: 0.9;
}

.charts-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 30px;
  margin-bottom: 40px;
}

.chart-container {
  background: #ffffff;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 25px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border: 1px solid #e2e8f0;
}

.chart-container h3 {
  margin-bottom: 20px;
  color: #2c3e50;
  font-size: 1.3rem;
}

.chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chart-bar {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  padding: 12px 15px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: transform 0.2s;
  min-height: 45px;
}

.chart-bar:hover {
  transform: translateX(5px);
}

.bar-label {
  font-weight: 600;
}

.bar-value {
  font-size: 0.9rem;
  opacity: 0.9;
}

.trend-chart {
  display: flex;
  align-items: end;
  gap: 15px;
  height: 200px;
  padding: 20px 0;
}

.trend-bar {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  flex: 1;
  border-radius: 8px 8px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: end;
  padding: 10px 5px;
  color: white;
  min-width: 50px;
  transition: transform 0.2s;
}

.trend-bar:hover {
  transform: translateY(-5px);
}

.trend-value {
  font-weight: bold;
  margin-bottom: 5px;
}

.trend-label {
  font-size: 0.8rem;
  opacity: 0.9;
}

.recent-activities {
  background: #f8f9fa;
  padding: 25px;
  border-radius: 15px;
  margin-bottom: 40px;
}

.recent-activities h3 {
  margin-bottom: 20px;
  color: #2c3e50;
  font-size: 1.3rem;
}

.activities-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.activity-item {
  background: white;
  padding: 15px 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.activity-icon {
  font-size: 1.5rem;
}

.activity-content {
  flex: 1;
}

.activity-title {
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 5px;
}

.activity-time {
  font-size: 0.9rem;
  color: #7f8c8d;
}

.activity-status {
  padding: 5px 12px;
  border-radius: 15px;
  font-size: 0.8rem;
  font-weight: 600;
}

.activity-status.success {
  background: #d4edda;
  color: #155724;
}

.activity-status.warning {
  background: #fff3cd;
  color: #856404;
}

.export-section {
  background: #f8f9fa;
  padding: 25px;
  border-radius: 15px;
}

.export-section h3 {
  margin-bottom: 20px;
  color: #2c3e50;
  font-size: 1.3rem;
}

.export-options {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.export-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.export-btn:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.export-icon {
  font-size: 1.2rem;
}

@media (max-width: 768px) {
  .summary-page {
    padding: 15px;
  }
  
  .summary-stats {
    grid-template-columns: 1fr;
  }
  
  .charts-section {
    grid-template-columns: 1fr;
  }
  
  .chart-container {
    padding: 20px;
  }
  
  .trend-chart {
    height: 150px;
  }
  
  .export-options {
    flex-direction: column;
  }
  
  .export-btn {
    justify-content: center;
  }
}
</style>